home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / djgpp / libsrc / c / dos / lock.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-01-09  |  913 b   |  44 lines

  1. /* This is file LOCK.C */
  2. /*
  3. ** Public domain, written by Pasi Eronen (pasi@forum.nullnet.fi).
  4. **
  5. ** This file is distributed WITHOUT ANY WARRANTY; without even the implied
  6. ** warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  7. */
  8.  
  9. #include <errno.h>
  10.  
  11. int _dos_lock(int, long, long);
  12. int _dos_unlock(int, long, long);
  13.  
  14. int lock(int fd, long offset, long length)
  15. {
  16.   int ret = _dos_lock(fd, offset, length);
  17.   /* change return code because Borland does it this way */
  18.   if (ret == 0x21)
  19.     ret = EACCES;
  20.   if (ret != 0)
  21.   {
  22.     errno = ret;
  23.     return(-1);
  24.   }
  25.   else
  26.     return(0);
  27. }
  28.  
  29. int unlock(int fd, long offset, long length)
  30. {
  31.   int ret = _dos_unlock(fd, offset, length);
  32.   /* change return code because Borland does it this way */
  33.   if (ret == 0x21)
  34.     ret = EACCES;
  35.   if (ret != 0)
  36.   {
  37.     errno = ret;
  38.     return(-1);
  39.   }
  40.   else
  41.     return(0);
  42. }
  43.  
  44.